﻿@using EMRI.EmergencyCare.Web.Helper
@using EMRI.EmergencyCare.Web.Models
@model IEnumerable<EMRI.EmergencyCare.Web.Helper.PatietViewModel>
@{
    ViewBag.Title = "Patient List";
}
<span>
    @Html.Partial("Create", new Patient())
</span>

<h3>Patient List - (@SessionHelper.GetLocation(Context)) </h3>
<table>
    <tr>
        <th colspan="8">
            <br />
        </th>
    </tr>
    <tr>
        <th>Patient ID
        </th>
        <th>Patient Name
        </th>
        <th>Date & Time
        </th>
        <th>Critical
        </th>
        <th>Emergency
        </th>
        <th>Referred Hospital
        </th>
        <th>Physician Name
        </th>
        <th>Action
        </th>
    </tr>
    @foreach (var viewModel in Model)
    {
        <tr>
            <td>
                @Html.ActionLink(viewModel.Patient.PatientId.ToString(), "Edit", new { patientId = viewModel.Patient.PatientId })
            </td>
            <td>
                @viewModel.Patient.Name
            </td>
            <td>
                @viewModel.Patient.CreatedDate.ToString("d")
            </td>
            <td>
                @(viewModel.Patient.IsCritical ? "Y" : "N")
            </td>
            <td>
                @viewModel.Patient.TypeOfEmergency
            </td>
            <td>
                @viewModel.Patient.HospitalName
            </td>
            <td>
                @viewModel.Patient.Doctor
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { patientId = viewModel.Patient.PatientId })
                <a class="print-label" data-src="@viewModel.Patient.PatientId" href="javascript:void(0)">Print</a>
                @if (viewModel.IsPatientDetailsAvailable)
                {
                    @Html.ActionLink("Details", "Details", new { patientId = viewModel.Patient.PatientId })   
                }
@*@Html.ActionLink("Delete", "Delete", new { id = item.PatientId })*@
            </td>
        </tr>
    }
</table>
<div class="printarea">
    Patient ID :
    <label>
    </label>
</div>
@section Scripts {
    <script type="text/javascript">
        $(function () {

            var $printArea = $(".printarea");
            $printArea.hide();

            $(".print-label").on("click", function () {
                var $idlabel = $printArea.find("label"),
                    $this = $(this);

                $idlabel.html($this.attr("data-src"));
                $printArea.print();
            });

        });
    </script>
}
